package com.querycenter.serviceimpl;

import java.util.ArrayList;
import java.util.List;

import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.querycenter.mapper.UserManageMapper;
import com.querycenter.model.UserInfo;
import com.querycenter.serviceinter.UserManageServiceInter;

import javassist.compiler.ast.Symbol;

public class UserManageServiceImpl extends BaseServiceImpl
		implements UserManageServiceInter {

	private UserManageMapper userManageDao = null;

	public UserManageMapper getUserManageDao() {
		return userManageDao;
	}

	public void setUserManageDao(UserManageMapper userManageDao) {
		this.userManageDao = userManageDao;
	}

	public PageList<UserInfo> selectUserAllInfo(int pageIndex, int pageSize) {
		try {
			return (PageList<UserInfo>) getPageList(UserManageMapper.class,
					"selectUserAllInfo", null, pageIndex, pageSize);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}

	@Override
	public void insertUser(UserInfo user) {

		userManageDao.insertUser(user);
	}

	public void updateUser(UserInfo user) {

		userManageDao.updateUser(user);
	}

	public void deleteUser(int id) {
		int lv = userManageDao.selectLvById(id);
		if (lv == 1) {
			userManageDao.updateLv3(id);
		} else {
			userManageDao.updateLv1(id);
		}
	}

	public int selectCount() {
		int count;
		count = userManageDao.selectCount();
		return count;
	}

}
